**//Common observations 2
**//Updated data - multiple sources 
clear
//log using "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\Table4 (Common Obs2).smcl", replace
set more off

use "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\pooled.dta", replace
drop countryname
sort country_id year

save "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\pooled1.dta", replace
use "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\paper.dta", replace
sort country_id year

merge country_id year using "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\pooled1.dta" 
order countryname year cncode country_id _merge

save "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\common1.dta",replace
keep if _merge==3

save "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\common2.dta",replace
drop if DKD_First == 9
drop if year < 1979

snapspan country_id year DKD_First , gen(year0) replace
rename year year1


**// STSETTING the dataset

stset year1 , origin(time year0) id(country_id) failure(DKD_First) exit(time .)
   
   
**********************
***Duration Models***
**********************

**// Duration Model (generating esample)

streg GDPgrowth_lag Infl  realintrate   depr tot creditgrowth  moralhak   ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica conav Ha, dist(exponential) nohr ///
vce(cluster country_id) time
gen aaa = e(sample)
 
**// Duration Model (Original Data) - column 2 

streg GDPgrowth_lag Infl  realintrate   depr tot creditgrowth  moralhak   ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha if IGDPgrowth_lag !=. & ///
WInfl !=. & Wrealintrate !=. & Idepr !=. & Dtot !=. & Gcreditgrowth !=. & ///
Imoralhak !=., dist(exponential) nohr ///
vce(cluster country_id) time

**// Duration Model (Multiple Source) - column 2

streg IGDPgrowth_lag WInfl  Wrealintrate Idepr Dtot Gcreditgrowth  Imoralhak ///
LegOrGer LegOrFre LegOrSca Africa Other  LatinAmerica Ha if aaa == 1, ///
dist(exponential) nohr vce(cluster country_id) time


**// Duration Model (Original Data) - column 3

streg GDPgrowth_lag Infl  realintrate   depr tot creditgrowth  moralhak   ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha conav if IGDPgrowth_lag !=. & ///
WInfl !=. & Wrealintrate !=. & Idepr !=. & Dtot !=. & Gcreditgrowth !=. & ///
Imoralhak !=., dist(exponential) nohr vce(cluster country_id) time

**// Duration Model (Multiple Source) - column 3

streg IGDPgrowth_lag WInfl  Wrealintrate Idepr Dtot Gcreditgrowth  Imoralhak  ///
LegOrGer LegOrFre LegOrSca Africa Other  LatinAmerica Ha conav ///
if  aaa == 1, dist(exponential) nohr vce(cluster country_id) time


********************
***Logit Models***
********************
clear
set more off
use "\\file\UsersW$\wrr15\Home\My Documents\My Files\SAMANGI BANDARANAYAKE\REPLICATION PAPER\REVISION FOR CRITICAL FINANCE REVIEW\DATA AND CODE\FILES FOR REVISED PAPER\common2.dta", replace

drop if  DKD_First == 9
keep if year > 1979

**// Logit Model (generating esample)

logit DKD_First GDPgrowth_lag Infl  realintrate  depr tot creditgrowth  moralhak ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha conav, vce(cluster country_id) 
gen bbb = e(sample)

**// Logit Model (Original Data) - column 6 

logit DKD_First GDPgrowth_lag Infl  realintrate  depr tot creditgrowth  moralhak ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha if IGDPgrowth_lag !=. & ///
WInfl !=. & Wrealintrate !=. & Idepr !=. & Dtot !=. & Gcreditgrowth !=. & ///
Imoralhak !=., vce(cluster country_id)
 
**// Logit Model (Multiple Source) - column 6

logit DKD_First IGDPgrowth_lag WInfl  Wrealintrate  Idepr Dtot Gcreditgrowth  Imoralhak ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha if bbb == 1, vce(cluster country_id)

**// Logit Model (Original Data) - column 7

logit DKD_First GDPgrowth_lag Infl  realintrate  depr tot creditgrowth  moralhak ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha conav if IGDPgrowth_lag !=. & ///
WInfl !=. & Wrealintrate !=. & Idepr !=. & Dtot !=. & Gcreditgrowth !=. & ///
Imoralhak !=., vce(cluster country_id)
 
**// Logit Model (Multiple Source) - column 7

logit DKD_First IGDPgrowth_lag WInfl  Wrealintrate Idepr Dtot Gcreditgrowth  Imoralhak ///
LegOrGer LegOrFre LegOrSca Africa Other LatinAmerica Ha conav if bbb == 1, vce(cluster country_id)

//log close
 
